<link rel="stylesheet" href="/Static/mobile/vant/index.css">
<link rel="stylesheet" href="/Static/mobile/applogin/css/mobilelogin.css?=1">
<script src="/Static/mobile/vant/vue.min.js"></script>
<script src="/Static/mobile/vant/vant.min.js"></script>
<style>
button, input, textarea{
    font-size: 13px;
}
</style>
<div  style="display:none;" id="app" class='conatainer'>
    <!--头部图片文件夹-->
    <div class='header-imgs-div'></div>
    <!--登陆-->
    <div class='login-div'>
        <p class='tele-p'>
            <img class='tele_pic' src="/Static/mobile/applogin/images/mobile.png" alt="" />
            <span class='add86'>+86</span>
            <input v-model="loginInfo.mobile" class='tele-inp' type="tel" placeholder="请输入您的手机号">
        </p>
        <p class='secure-p'>
            <img class='mobile-secure' src="/Static/mobile/applogin/images/secure.png" alt="">
            <input v-model="loginInfo.code" class='secure-inp' type="text" placeholder="请输入验证码">
            <button @click="sendSmsCode" class='get-btn'>{{sendText}}<span v-if="sendNum!=0">{{sendNum}}</span></button>
        </p>
    </div>

    <div class='login-bottom'>
        <button @click="mobileLogin">登陆</button>
        <p class='choose'>
            <!--添加active class名即为选中-->
            <span class='aggre active'>您同意</span>
            <span @click="location.href='http://aidu.v801.cn/mobile/article?article_id=27'" class='xieyi'>《全球伯乐用户协议》</span>
        </p>

    </div>
    <p class='bottom_tip bottom-fixed'>伯乐，只给你最需要的</p>
</div>


<script>
    function vueInit () {
        var app = new Vue({
            el: '#app',
            data: {
                loginInfo:{},
                register:{},
                haswx: false,
                activeTab:0,
                sendNum:0,
                sendText:'获取验证码'
            },
            watch: {
                sendNum: function (val,oldval) {
                    if(val!=0) {
                        this.sendText = '已发送';
                    }else{
                        this.sendText = '发送验证码';
                        clearInterval(window.sendTask);
                    }
                }
            },
            created:function () {
                var self = this;
            },
            mounted: function () {
                $('#app').show();
            },
            methods: {
                sendSmsCode: function () {
                    var self = this;
                    if(!this.loginInfo.mobile) {
                        this.$toast('请输入手机号');
                        return;
                    }
                    if(this.sendText!='获取验证码') {
                        return false;
                    }
                    var url = "/mobile/login/sendsms?mobile="+this.loginInfo.mobile;
                    $.get(url).then(function(res){
                        if(res.ret==1) {
                            showerror(res.msg);
                        }else{
                            self.sendNum = 60;
                            window.sendTask = setInterval(function(){
                                self.sendNum--;
                            },1000)
                        }
                    });
                },
                mobileLogin: function() {
                    var data = this.loginInfo;
                    if(!data.mobile) {
                        this.$toast('请输入手机号');
                        return;
                    }
                    if(!data.code) {
                        this.$toast('请输入验证码');
                        return;
                    }
                    $.ajax({
                        type: 'post',
                        data: data,
                        url: '/mobile/login/appmobile'
                    }).then(function(res) {
                        if(res.ret==0) {
                            plus.storage.setItem('token', getCookie('token'));
                            window.location.replace(res.url);
                        }else{
                            showerror(res.msg);
                        }
                    })
                }
            }
        });
    }
    document.addEventListener("plusready",function(){
        vueInit();
    },false);
    
    
</script>
<style>
    .van-cell__title {
        max-width: 90px;
    }
    .van-cell__value {
        text-align: left;
    }
</style>
